From: Keir Fraser Date: Thu, 15 Oct 2009 07:31:08 +0000 (+0100) Subject: xm: Reuse VDI if location is same X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13223 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=f8e61527db79a580d9d9d5602059ed4db6c06b2d;p=xen.git xm: Reuse VDI if location is same In XenAPI mode, when we start a VM by using xm create command, VDIs are always automatically created for VBDs. Once we shut down the VM, then start the VM again, then VDIs are newly created. As a result, a vdi.xml file continues to expand. This patch reuses VDIs if location of the VDIs is same. Signed-off-by: Masaki Kanno --- diff --git a/tools/python/xen/xm/xenapi_create.py b/tools/python/xen/xm/xenapi_create.py index 903b29d21a..6af21188a9 100644 --- a/tools/python/xen/xm/xenapi_create.py +++ b/tools/python/xen/xm/xenapi_create.py @@ -215,6 +215,16 @@ class xenapi_create: def create_vdi(self, vdi): log(DEBUG, "create_vdi") + for ref, record in server.xenapi.VDI.get_all_records().items(): + location = record["other_config"]["location"] + if vdi.attributes["src"].value != location: + continue + + # Reuse the VDI because the location is same. + key = vdi.attributes["name"].value + return (key, ref) + + # Create a new VDI. vdi_record = { "name_label": get_name_label(vdi), "name_description": get_name_description(vdi),